// .........................................................................
// Title: gz_events.do
//
// Overlays the event windows of interest on a plot of the time series of
// the GZ credit spread
// .........................................................................

* Plot GZ index and event windows (Figure 2)
use "$tmp/gz_index", clear
keep if date_m >= tm(2005m1)
gen event_min = 0
gen event_max = 8
local graph_end = .5
gen _range1 = date_m if date_m >= tm(2007m6) & date_m < tm(2008m12) + `graph_end'
gen _range2 = date_m if date_m >= tm(2014m8) & date_m < tm(2016m2) + `graph_end'
gen _range3 = date_m if date_m >= tm(2011m4) & date_m < tm(2011m10) + `graph_end'
gen _range4 = date_m if date_m >= tm(2020m1) & date_m < tm(2020m3) + `graph_end'
format %tm _range*

twoway (rarea event_max event_min _range1, color(gs8%30)) ///
       (rarea event_max event_min _range2, color(gs8%30)) ///
       (rarea event_max event_min _range3, color(gs8%30)) ///
       (rarea event_max event_min _range4, color(gs8%30)) ///
       (line gz_spread date_m, lcolor(red)), ///
    graphregion(color(white)) xtitle("") ytitle("Gilchrist-Zakrajšek Credit Spread") legend(off) xsize(7) ///
    ylab(0 "0%" 2 "2%" 4 "4%" 6 "6%" 8 "8%")

graph export "$graphs/gz_events.pdf", as(pdf) replace
